<template>
    <el-row class="el-row">
      <el-col :span="6" :offset="6">
        <!-- 收集输入的数据，收集完毕之后将其传入到app当中 子传父 -->
        <el-input placeholder="请输入数据" v-model="title"></el-input>
      </el-col>
      <el-col :span="3">
        <el-button type="success" @click="addItem">添加数据</el-button>
      </el-col>
    </el-row>
  </template>
  
  <script lang="ts">
  import { defineComponent, ref } from "vue";
  
  export default defineComponent({
    setup(props, { emit }) {
      const title = ref<string>("");
      console.log(title);
      // 点击添加数据按钮完成子传父
      const addItem = () => {
        emit("add", title.value);
      };
      return {
        title,
        addItem,
      };
    },
  });
  </script>
  
  <style scoped>
  </style>